using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web;
using System.Data.SqlClient;

public partial class WSingle_WSingle : System.Web.UI.Page
{
    private ReportDocument reportdoc = null;

    protected void Page_Load(object sender, EventArgs e)
    {

       
    }
    protected void Page_UnLoad(object sender, System.EventArgs e)
    {
        reportdoc.Dispose();

    }
    protected override void OnPreInit(EventArgs e)
    {       
        string prinid=Request.Params["printId"];
        if (prinid == null)
        {            
            return;
        }
        reportdoc = new ReportDocument();
        reportdoc.Load(Server.MapPath("UseCarReport.rpt"));        
        string selectSql= @"SELECT     
                            Services_UseCars.UseCarId, 
                            Services_UseCars.CarId, 
                            Services_SV_Cars.CarName, 
                            Services_UseCars.EmployeeId, 
                            Employees.EmpName, 
                            Department.DepartmentName,
                            Services_UseCars.PeoCount, 
                            Services_UseCars.Cause, 
                            Services_UseCars.Client, 
                            Services_UseCars.UCDate, 
                            Services_UseCars.UOutHour, 
                            Services_UseCars.UOutMinute, 
                            Services_UseCars.UBackHour, 
                            Services_UseCars.UBackMinute, 
                            Services_UseCars.GetOnAddress, 
                            Services_UseCars.PreWay, 
                            Services_UseCars.DOutDate, 
                            Services_UseCars.DBackDate, 
                            Services_UseCars.SCLM, 
                            Services_UseCars.XCLM, 
                            Services_UseCars.UseKil, 
                            Services_UseCars.FactWay, 
                            Services_UseCars.UserId,
                            Services_UseCars.FlowFlag, 
                            SYS_FlowFlag.FlowFlagName
                        FROM         
                            Services_UseCars LEFT OUTER JOIN
                                              Services_SV_Cars ON Services_UseCars.CarId = Services_SV_Cars.CarId 
                                         LEFT OUTER JOIN
                                              Employees ON Services_UseCars.UserId = Employees.EmployeeID 
                                         LEFT OUTER JOIN
                                              Department ON Employees.DepartmentId=Department.DepartmentId 
                                         LEFT OUTER JOIN
                                              SYS_FlowFlag ON Services_UseCars.FlowFlag = SYS_FlowFlag.FlowFlag 
                        where Services_UseCars.UseCarId in " + prinid;

        object[] objParam = new object[2];
        objParam[0] = selectSql;
        objParam[1] = "Services_UseCars";
        object[] myRet = Srvtools.CliUtils.CallMethod("ServiceSheet", "ExecSqlByDataSet", objParam);
        DataSet ds = (DataSet)myRet[1];
        reportdoc.SetDataSource(ds);
        this.CrystalReportViewer1.ReportSource = reportdoc;





    }

    

    
    
}
